/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2025-04-06
 * Time: 16:22
 */
public class Demo12 {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
           while(!Thread.currentThread().isInterrupted()) {
               System.out.println("hello thread");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   //线程掀桌
//                   e.printStackTrace();
                   break;
               }
           }
            System.out.println("t线程结束");
        });
        t.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Main线程尝试中断t线程");
        t.interrupt();
    }
}
